]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Move child focus handling to IconGrid
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 19 May 2020 18:34:11 +0000 (15:34 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 18 Jun 2020 13:30:12 +0000 (10:30 -0300)
The icon grid is always paginated, so the app grid code doesn't need
to behave differently in the FolderView and AppDisplay.

Move the keyboard handling to IconGrid itself, and remove the now dead
code from AppDisplay.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1271

js/ui/appDisplay.js
js/ui/iconGrid.js

index 6bd3b614518a4c63116841e7a71e2b48e0960d5c..0b545230a6b7c998bb46b2b9b316981d86fc93f9 100644 (file)
@@ -121,9 +121,6 @@ var BaseAppView = GObject.registerClass({
         super._init(params);
 
         this._grid = new IconGrid.IconGrid();
-        this._grid.connect('child-focused', (grid, actor) => {
-            this._childFocused(actor);
-        });
         // Standard hack for ClutterBinLayout
         this._grid.x_expand = true;
 
@@ -141,10 +138,6 @@ var BaseAppView = GObject.registerClass({
         });
     }
 
-    _childFocused(_actor) {
-        // Nothing by default
-    }
-
     _redisplay() {
         let oldApps = this._orderedItems.slice();
         let oldAppIds = oldApps.map(icon => icon.id);
@@ -697,10 +690,6 @@ class AppDisplay extends BaseAppView {
         });
     }
 
-    _childFocused(icon) {
-        let itemPage = this._grid.getItemPage(icon);
-        this.goToPage(itemPage);
-    }
 
     // Called before allocation to calculate dynamic spacing
     adaptToSize(width, height) {
@@ -1022,10 +1011,6 @@ class FolderView extends BaseAppView {
         super.vfunc_allocate(box);
     }
 
-    _childFocused(actor) {
-        Util.ensureActorVisibleInScrollView(this._scrollView, actor);
-    }
-
     // Overridden from BaseAppView
     animate(animationDirection) {
         this._grid.animatePulse(animationDirection);
index b6874d5b6c3a2fa0e7cd6f680555c7955016b114..2d2b4548d267ed196fa398ec63f612b7ccd6c8c1 100644 (file)
@@ -1143,7 +1143,6 @@ var IconGrid = GObject.registerClass({
     Signals: {
         'pages-changed': {},
         'animation-done': {},
-        'child-focused': { param_types: [Clutter.Actor.$gtype] },
     },
 }, class IconGrid extends St.Viewport {
     _init(layoutParams = {}) {
@@ -1199,7 +1198,9 @@ var IconGrid = GObject.registerClass({
     }
 
     _childAdded(grid, child) {
-        child._iconGridKeyFocusInId = child.connect('key-focus-in', actor => this.emit('child-focused', actor));
+        child._iconGridKeyFocusInId = child.connect('key-focus-in', () => {
+            this._ensureItemIsVisible(child);
+        });
 
         child._paintVisible = child.opacity > 0;
         child._opacityChangedId = child.connect('notify::opacity', () => {
@@ -1210,6 +1211,14 @@ var IconGrid = GObject.registerClass({
         });
     }
 
+    _ensureItemIsVisible(item) {
+        if (!this.contains(item))
+            throw new Error(`${item} is not a child of IconGrid`);
+
+        const itemPage = this.layout_manager.getItemPage(item);
+        this.goToPage(itemPage);
+    }
+
     _setGridMode(modeIndex) {
         if (this._currentMode === modeIndex)
             return;